package xyz.labradormm.spider.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.labradormm.spider.constant.RedisKeyPrefix;
import xyz.labradormm.spider.domain.dto.Result;
import xyz.labradormm.spider.domain.dto.SysConfigDto;
import xyz.labradormm.spider.enums.SpiderType;

/**
 * @author huanghaojian
 * @description
 * @date 2023-12-11 23:50
 */
@RestController
@RequestMapping("sys/config")
public class SysConfigController {

    @Autowired
    private RedisTemplate<String,String> redisTemplate;


    @PostMapping("saveYtCookies")
    public Result saveYtCookies(@RequestBody SysConfigDto sysConfigDto){
        String key=String.format(RedisKeyPrefix.SPIDER_CONFIG_AUTH_INFO, SpiderType.youtube.getCode());
        redisTemplate.opsForValue().set(key,sysConfigDto.getCookies());
        return Result.success();
    }


}
